<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv='refresh' content='60'>
	<title><?php echo $view_title?></title>
	<link rel=stylesheet href='./template/<?php echo $OJ_TEMPLATE?>/<?php echo isset($OJ_CSS)?$OJ_CSS:"hoj.css" ?>' type='text/css'>
   <script type="text/javascript" src="include/jquery-latest.js"></script> 
<script type="text/javascript" src="include/jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function() 
    { 
 $.tablesorter.addParser({ 
        // set a unique id 
        id: 'punish', 
        is: function(s) { 
            // return false so this parser is not auto detected 
            return false; 
        }, 
        format: function(s) { 
            // format your data for normalization 
	    var v=s.toLowerCase().replace(/\:/,'').replace(/\:/,'').replace(/\(-/,'.').replace(/\)/,''); 
	    //alert(v);
	    v=parseFloat('0'+v);
	    return v>1?v:v+Number.MAX_VALUE-1;
        }, 
        // set type, either numeric or text 
        type: 'numeric' 
    }); 

        $("#rank").tablesorter({ 
            headers: { 
                4: { 
                    sorter:'punish' 
                }
		
<?php
for ($i=0;$i<$pid_cnt;$i++){
                echo ",".($i+5).": { ";
                echo "    sorter:'punish' ";
                echo "}";
}
?>
            } 
        }); 
    } 
);
</script>
</head>
<body>
<div id="wrapper">
<div id=main>
<?php 
require_once("contest-header.php");?>
<?php
$rank=1;
?>
<center><h3>School RankList -- <?php echo $title?></h3><!--<a href="contestrank.xls.php?cid=<?php echo $cid?>" >Download</a>--><?php if($locked==true) echo"<font color=red>已封榜</font>";?></center>
<center><h5>Summary of top <?php echo $TOPSCHOOLNUM;?> teams from every school</h5>
<?php 
if(isset($_SESSION['administrator'])) 
	echo "<a href='schoolrank.xls.php?cid=".$cid."' >Download_The_School_RankList</a>";
?>
</center>

<!--<center><h3><font color=red>新功能测试，勿在意。</font></h3></center>-->
<table id=rank><thead><tr class=toprow align=center><td class="{sorter:'false'}" width=5%>Rank<th width=10%>School<th width=5%>Solved<th width=5%>Penalty
<?php
for ($i=0;$i<$pid_cnt;$i++)
	echo "<th class=\"{sorter:'punish'}\"><a href=problem.php?cid=$cid&pid=$i>$PID[$i]</a>";
     echo "</tr></thead>\n<tbody>";
for ($i = 0; $i < $schcnt; $i++)
{
    if ($i & 1) echo "<tr class=oddrow align=center>\n";
    else echo "<tr class=evenrow align=center>\n";
    echo "<td>";
    $uuid = $schor[$i]->user_id;
    $sschool = $schor[$i]->school;
    echo $rank++;
    $usolved = $schor[$i]->solved;
   	echo"<td>$sschool";
    echo "<td>$usolved";
    echo "<td>".sec2str($schor[$i]->time);
    for ($j = 0; $j < $pid_cnt; $j++)
    {
        $bg_color = "eeeeee";
        if (isset($schor[$i]->p_ac_sec[$j]) && $schor[$i]->p_ac_sec[$j] > 0)
        {
          //  $bg_color = "33ff33";


            $bg_color="aaffaa";
            if($uuid == $first_blood[$j])
            {
                $bg_color = "aaaaff";
            }



        }
        else if(isset($schor[$i]->p_wa_num[$j]) && $schor[$i]->p_wa_num[$j] > 0)
        {
            $bg_color = "ff8c8c";
        }


        echo "<td class=well style='padding:1px;background-color:$bg_color'>";
        if(isset($schor[$i]))
        {
            if (isset($schor[$i]->p_ac_sec[$j]) && $schor[$i]->p_ac_sec[$j] > 0)
                echo $schor[$i]->p_ac_sec[$j];
            if (isset($schor[$i]->p_wa_num[$j]) && $schor[$i]->p_wa_num[$j] > 0)
                echo "(-".$schor[$i]->p_wa_num[$j].")";
        }
    }
    echo "</tr>\n";
}
     echo "</tbody></table>";
?>




</script>

<div id=foot>
<?php require_once("oj-footer.php");?>

</div><!--end foot-->
</div><!--end main-->
</div><!--end wrapper-->
</body>
</html>
